package com.shtel.customerInfo.controller;


import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.shtel.customerInfo.entity.*;
import com.shtel.customerInfo.mapper.QueryMapper;
import com.shtel.customerInfo.service.CustomerInfoService;
import com.shtel.customerInfo.util.Cors;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@DefaultProperties(defaultFallback = "fallback", commandProperties = {@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "3000")})
@Api(description = "用户信息服务接口")
@RestController
public class CustomerInfoController extends Cors {
    @Autowired
    QueryMapper queryMapper;
    @Autowired
    CustomerInfoService customerInfoService;


    private String fallback() {
        return "哎呀，服务器开小差了！请稍后再试。";
    }

    //310320199506061234
    @ApiOperation(value = "根据身份证获取客户信息", notes = "获取客户信息")
    @GetMapping("queryCustInfo/{creditnum}")
    public CustInfo queryCustInfo(@PathVariable String creditnum) {
        return customerInfoService.queryCustInfo(creditnum);

    }


    //查询客户经理信息
    @ApiOperation(value = "查询客户经理信息", notes = "查询客户经理信息")
    @GetMapping("queryceoinfo/{ceonumber}")
    public CeoInfo queryceoinfo(@PathVariable String ceonumber) {

        return customerInfoService.queryceoinfo(ceonumber);
    }

    //查询客户经理团队信息
    @ApiOperation(value = "查询客户经理团队信息", notes = "查询客户经理团队信息")
    @GetMapping("queryceoinfos/{ceogroupid}")
    public List<CeoInfo> queryceoinfos(@PathVariable String ceogroupid) {

        return customerInfoService.queryceoinfos(ceogroupid);

    }

    //查询政企客户信息
    @ApiOperation(value = "查询政企客户信息", notes = "查询政企客户信息")
    @GetMapping("querygovcustinfo/{govid}")
    public GovCustInfo querygovcustinfo(@PathVariable String govid) {
        return customerInfoService.querygovcustinfo(govid);
    }

    //查询政企客户树(根据查询政企客户经理来)
    @ApiOperation(value = "查询政企客户树(根据查询政企客户经理来)", notes = "查询政企客户树(根据查询政企客户经理来)")
    @GetMapping("querygovcusttree/{govid}")
    public GovCustNode querygovcusttree(@PathVariable String govid) {

        return customerInfoService.querygovcusttree(govid);
    }

    //查询星级服务
    @ApiOperation(value = "查询星级服务", notes = "查询星级服务")
    @GetMapping("querystarandscore/{creditnum}")
    public StarAndScore querystarandscore(@PathVariable String creditnum) {

        return customerInfoService.querystarandscore(creditnum);
    }

    @GetMapping("test/{govid}")
    public List<GovCeoInfo> ishealth(@PathVariable String govid) {
        List<GovCeoInfo> govCeoInfos = queryMapper.queryGovCeoInfos(govid);

        return govCeoInfos;
    }

}
